/*
* js4eos Powered by Eosfavor
* Jack Itleaks @2018
* itleaks@126.com
*/
const path = require('path')
const fs = require('fs')
exports.command = 'create <contract>'
exports.desc = 'Create an contract'
exports.builder = {}
exports.handler = function (argv) {
    var currentDir = process.cwd()
    var configFile = path.join(currentDir, "js4eos_config.js")
    if (!fs.existsSync(configFile)) {
        console.log("Not found js4eos application")
        return;
    }

    var contractDir = path.join('./contracts', argv.contract)
    var contractFile = path.join(contractDir, argv.contract + ".cpp")
    try {
        fs.mkdirSync(contractDir, '0777', true)
        fs.writeFileSync(contractFile, "// Generated by Js4eos.Enjoy programing a EOS contract")
    } catch(e) {
        console.log(e)
    }
}